<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<script type="text/javascript">
    var getValue,setValue;

    (function(){
        var secret = 0;

        getValue = function(){
            return secret;
        }

        setValue = function(v){
            if(typeof v === 'number'){
                secret = v;
            }
        }
    })();

    console.log(getValue());

    setValue(123);
    console.log(getValue());

    setValue(1543);
    console.log(getValue());
</script>
<script type="text/javascript">
    function setup(x){
        var i = 0;
        return function(){
            console.log('i = ' + i);
            return x[i++];
        }
    }

    var next = setup(['a','b','c']);

    console.log(next());
    console.log(next());
    console.log(next());
    console.log(next());
</script>
</body>
</html>
